package com.owc.common.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum FlowTypeEnum {
	recharge(10,"充币"),
	withdraw(20,"提币"),
	miner(30,"矿工费"),
	platformOut(40,"平台转出"),
	platformIn(50,"平台转入"),
	withdrawCost(60,"提币手续费"),
	withdrawRefuseBack(70,"提币不通过退回"),
	withdrawRefuseCostBack(80,"提币手续费退回"),
	drawIn(90,"划入"),
	drawOut(100,"划出"),
	redemption(110,"赎回"),
	lock(120,"锁仓"),
	exchange(130,"兑换"),
	INCOME(140,"理财收益");


	private Integer type;

	private String desc;

	FlowTypeEnum(Integer type, String desc) {
		this.type = type;
		this.desc = desc;
	}

	public static Optional<FlowTypeEnum> match(Integer type) {
		return Arrays.stream(FlowTypeEnum.values())
				.filter(t -> t.getType().equals(type))
				.findFirst();
	}

	public static FlowTypeEnum findByDesc(String desc){
		return Arrays.stream(FlowTypeEnum.values())
				.filter(t -> t.getDesc().equals(desc))
				.findFirst().orElse(null);
	}

}
